<?php

class UserType {
	private $id;
	private $description;
	
	function __construct($id,$description){
		$this -> id = $id;
		$this -> description = $description;
	}
	
	
	function getUserType($db,$id){
		$result=$db->query("SELECT * FROM user_type WHERE ut_IDtype = $id",2);
		$usertype=new UserType($result[0]['ut_IDtype'],
							$result[0]['ut_description']);
				
		return $usertype;
	
	}
	
	function getList($db){
		$result=$db->query("SELECT * FROM user_type",2);
		return $result;
	}
	
	function insert($db,$usertype){
		$description 	= $usertype -> getDescription();
		$result=$db->insert("INSERT INTO user_type (ut_description) VALUES('".addslashes(utf8_decode($description))."')");
		return $result;
	}	
	
	function delete($db,$usertype){
		$id 			= $usertype -> getID();
		$result=$db->delete("DELETE FROM user_type WHERE ut_IDtype = " . $id);
		return $result;
	}	
	
	function update($db,$usertype){
		$id 			= $usertype -> getID();
		$description	= $usertype -> getDescription();
		$result=$db->update("UPDATE user_type SET ut_description='".addslashes(utf8_decode($description))."' WHERE ut_IDtype = " . $id);
		return $result;
	}		
	
	
	function getID(){
		return $this -> id;
	}
	
	function  setID($id){
		$this -> id = $id;
	}
	
	function getDescription(){
		return $this -> description;
	}
	
	function  setDescription($description){
		$this -> description = $description;
	}
}

?>